package edu.uta.cse6339.facetedinterface.read.article.labels;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class HateCrimeLabeledArticles {

	private static HashMap<String,Set<String>> classifedArticles = new HashMap<String,Set<String>>();
	private static String sexual_keywords[] ={"sexual","male homosexu","femal homosexu","heterosexu","bisexu","hate"};
	private static String race_keywords[] =  {"White","Black","Asian","Hispan","ethnic","Jewish","Cathol","Protest","Islamic","religi group","african","african-american"}; 


	//private static final String HATE_CRIME_LABELED_FILE_NAME="src/edu/uta/cse6339/facetedinterface/resources/classified/hateCrimeOutFile.txt";
	private static final String HATE_CRIME_LABELED_FILE_NAME="data/output/hateCrimeOutFile.txt";
	
	public static void initialise(){
		classifedArticles= ReadClassfiedArticleLabels.readArticleLabels(HATE_CRIME_LABELED_FILE_NAME);
	}
	
	public static Set<String> getArticlesByRace(){
		Set<String> raceArticles = new HashSet<String>();
		ArrayList<Set<String>> setList = new ArrayList<Set<String>>();
		
		for(String token: race_keywords){
			Set<String> raceTokenArticles=classifedArticles.get(token.trim().toLowerCase());
			if(raceTokenArticles!=null && raceTokenArticles.size()>0){
		//		System.out.println(state+" articles "+stateArticles);
				setList.add(raceTokenArticles);
			}
		}
		if(setList!=null && setList.size()>0){
			raceArticles.addAll(setList.get(0));
			for(Set<String> articleSet : setList){
				raceArticles.retainAll(articleSet);
			}
		}

		return raceArticles;
	}
	
	public static Set<String> getArticlesBySexual(){
		Set<String> raceArticles = new HashSet<String>();
		ArrayList<Set<String>> setList = new ArrayList<Set<String>>();
		
		for(String token: sexual_keywords){
			Set<String> raceTokenArticles=classifedArticles.get(token.trim().toLowerCase());
			if(raceTokenArticles!=null && raceTokenArticles.size()>0){
		//		System.out.println(state+" articles "+stateArticles);
				setList.add(raceTokenArticles);
			}
		}
		if(setList!=null && setList.size()>0){
			raceArticles.addAll(setList.get(0));
			for(Set<String> articleSet : setList){
				raceArticles.retainAll(articleSet);
			}
		}

		return raceArticles;

	}

	
	public static void main(String args[]){
		initialise();
		System.out.println(getArticlesBySexual());
	}


}
